package com.joking.controller;

import com.joking.config.Constants;
import com.joking.entity.Simple;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class TestController {

    @Resource
    private RabbitTemplate rabbitTemplate;

    @GetMapping("/produce")
    public void produce() {
        Simple simple = new Simple();
        simple.setId(System.currentTimeMillis());
        simple.setName("张三" + System.currentTimeMillis());
        rabbitTemplate.convertAndSend(Constants.SIMPLE_QUEUE, simple);
    }
}
